﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NEmu;

namespace Super64.Core.Memory.Ram.MemoryPages
{
    public sealed class RDRAMMemoryPage : MemoryPage
    {
        private byte[] m_Buffer;

        public RDRAMMemoryPage()
        {
            m_Buffer = new byte[Size - 0xFFFF];
        }

        public override byte Read(ulong address)
        {
            // Unused memory
            if (address > (Size - 0xFFFF))
                return 0;

            return m_Buffer[address];
        }

        public override void Write(ulong address, byte value)
        {
            if (address > (Size - 0xFFFF))
                return;

            m_Buffer[address] = value;
        }

        public override ulong Size
        {
            get { return 0x03EFFFFFUL; }
        }

        public override void Clear()
        {
            Array.Clear(m_Buffer, 0, m_Buffer.Length);
        }

        public override void Dispose()
        {
            m_Buffer = null;
        }
    }
}
